{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "from tensorflow.python.framework import ops\n",
    "import matplotlib.pyplot as plt\n",
    "import os\n",
    "\n",
    "ops.reset_default_graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sess = tf.Session()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 创建测试数据\n",
    "x_vals = np.random.normal(1,0.1,100)\n",
    "y_vals = np.repeat(10.,100)\n",
    "\n",
    "x_data = tf.placeholder(shape=[None,1],dtype=tf.float16)\n",
    "y_data = tf.placeholder(shape=[None,1],dtype=tf.float16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "#创建模型\n",
    "w = tf.Variable(tf.random_normal(shape=[1,1],dtype=tf.float16))\n",
    "out = tf.matmul(x_data,w)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "# loss\n",
    "loss =tf.reduce_mean(tf.square( out - y_data ))\n",
    "opt = tf.train.GradientDescentOptimizer(0.02)\n",
    "train_step = opt.minimize(loss)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sess.run(tf.global_variables_initializer())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss =  66.7\n",
      "loss =  44.47\n",
      "loss =  30.31\n",
      "loss =  22.33\n",
      "loss =  12.63\n",
      "loss =  9.88\n",
      "loss =  6.465\n",
      "loss =  4.426\n",
      "loss =  2.914\n",
      "loss =  2.414\n",
      "loss =  1.697\n",
      "loss =  2.365\n",
      "loss =  1.251\n",
      "loss =  1.6455\n",
      "loss =  1.157\n",
      "loss =  1.126\n",
      "loss =  1.64\n",
      "loss =  0.602\n",
      "loss =  1.644\n",
      "loss =  0.6113\n"
     ]
    }
   ],
   "source": [
    "batch_size = 25\n",
    "batch_loss = []\n",
    "for i in range(len(x_vals)):\n",
    "    random_index = np.random.choice(100,batch_size)\n",
    "    x_input = np.transpose([x_vals[random_index]])\n",
    "    y_input = np.transpose([y_vals[random_index]])\n",
    "    sess.run(train_step,feed_dict={x_data:x_input,y_data:y_input})\n",
    "    if((i+1) %5) == 0:\n",
    "        temp_loss = sess.run(loss,feed_dict={x_data:x_input,y_data:y_input})\n",
    "        batch_loss.append(temp_loss)\n",
    "        print(\"loss = \",temp_loss)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "ops.reset_default_graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sess = tf.Session()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 创建测试数据\n",
    "x_vals = np.random.normal(1,0.1,100)\n",
    "y_vals = np.repeat(10.,100)\n",
    "\n",
    "x_data = tf.placeholder(shape=[1],dtype=tf.float16)\n",
    "y_data = tf.placeholder(shape=[1],dtype=tf.float16)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [],
   "source": [
    "#创建模型\n",
    "w = tf.Variable(tf.random_normal(shape=[1],dtype=tf.float16))\n",
    "out = tf.multiply(x_data,w)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# loss\n",
    "loss =tf.reduce_mean(tf.square( out - y_data ))\n",
    "opt = tf.train.GradientDescentOptimizer(0.02)\n",
    "train_step = opt.minimize(loss)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sess.run(tf.global_variables_initializer())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss =  55.3\n",
      "loss =  34.6\n",
      "loss =  21.5\n",
      "loss =  14.9\n",
      "loss =  10.44\n",
      "loss =  4.957\n",
      "loss =  2.875\n",
      "loss =  2.64\n",
      "loss =  1.467\n",
      "loss =  0.6104\n",
      "loss =  3.398\n",
      "loss =  0.673\n",
      "loss =  0.09766\n",
      "loss =  0.725\n",
      "loss =  0.007385\n",
      "loss =  2.795\n",
      "loss =  0.04126\n",
      "loss =  2.297\n",
      "loss =  0.03815\n",
      "loss =  0.4104\n"
     ]
    }
   ],
   "source": [
    "stochastic_loss = []\n",
    "for i in range(len(x_vals)):\n",
    "    random_index = np.random.choice(100)\n",
    "    x_input = [x_vals[random_index]]\n",
    "    y_input = [y_vals[random_index]]\n",
    "    sess.run(train_step,feed_dict={x_data:x_input,y_data:y_input})\n",
    "    if((i+1) %5) == 0:\n",
    "        temp_loss = sess.run(loss,feed_dict={x_data:x_input,y_data:y_input})\n",
    "        stochastic_loss.append(temp_loss)\n",
    "        print(\"loss = \",temp_loss)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xd8VNW2wPHfSkIIUqQYakSKCEiHUESkCtKegIDiRQVF\nEUHFgl68Vq56AfUpXgWvNEWsSHmgF7EgiNIkQgQ0IIqCUZoUaZKQZL0/9oQESJmEmUlmsr6fz3ym\n7TNnzUxY7Nlnn7VFVTHGGBP8wgo6A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UqVYuHAhjzzyCOHh4aSkpPDyyy/TsWNHxo0bxzvvvENUVBQi\nwrJlyyhbtmyO+8ir4Ejo4eFwxRXWQzemEPn44485ePAg33//PQAHDx4EYPLkyYwZM4b0QnzJycn0\n79+fmTNncuWVV7J06VL69+/Pjz/+yC+//MKtt97Kl19+SZ06dUhKSiI5OfnUPsqUKcO6detYuXIl\n11577amE/uKLL3LBBRcA8MgjjzBx4kQmTJjAlClT6NmzJ48++uipmMqVK8eIESM4evQozz33HOB+\nRaQ7cOAA/fr1Y/78+bRt25bU1FQOHz6c43v/6KOPmD17NqtWraJ06dIMGTKEJ598kokTJ/LYY48x\nZcoUrrjiClJTUzl27BgHDx7kueeeY+/evZQoUYIjR45QokQJH3wLpwuOhA7Qvz+sWgUpKRARPGEb\n4y+59aD9rUmTJmzZsoVRo0bRsWNHevXqlWW7rVu3EhkZyZVXXglAly5diIyMZOvWraxYsYKePXtS\np04dAIoXL07x4sVPbTto0CAA2rRpw++//86JEyeIiorijTfe4K233iI5OZljx45xySWXANC+fXvG\njBlDcnIynTp18mqcfPXq1Vx66aW0bdsWgPDwcMqVy3kBtvSefpkyZQAYPnw4o0ePBqBz587cf//9\nDBw4kB49etCwYUNSU1OpW7cuN9xwA927d6d3796ULl0619jyKjjG0AGGDIFXX7VkbkwhUatWLRIS\nEujatSufffYZTZo0yXIetapmOSVPRMitfHdUVBTgkixASkoKX375Ja+88gpLlixh06ZNPPXUU6f2\n279/f1auXEnt2rWZMGECN3oxRJuXVdsyb3Pme0q//8ILLzBjxgwiIyMZOHAg06ZNIzw8nDVr1nD3\n3XeTmJhIixYt2LhxY573m5vgSejgZrvs2ZN7O2OM3yUmJhIeHk7fvn154YUX2LdvHwcOHKBMmTL8\n+eefp9rVq1ePpKSkUwchly1bxsmTJ7nkkku46qqrWLx4Mdu2bQMgKSnp1Dh2dg4dOsT5559PhQoV\nSEpKYubMmaee+/HHH6lcuTJDhw7l8ccf5+uvvwY4K6bM2rZty/fff8/q1asBSE1NP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HsClwPUicmnBRuV3KcD9qlofaAOM8rznscBSVa0DLPXcD1Wj\ngYRM9ycCL3je+0FgWIFEFTgvAktUtR7QBPdZFInvX0SqAXcDsaraEFeeexBF728gzwp9QgdaAT+q\n6nZVTQbeBfoUcEx+paq7VHW95/YR3D/marj3PcvTbBbQt2Ai9C8RiQF6AdM99wXoDMz1NAnZ9w4g\nImWA9sAMAFVNVtVDFJHv3yMCKCEiEcB5wC6K0N9AfgVDQq8G/JrpfqLnsSJBRGoAzYC1QCVV3QUu\n6QMVCy4yv5oEPAikr3tfATikqime+6H+N1AL2Ae85hl2mi4iJSki37+q/gY8B+zEJfI/gW8oWn8D\n+RIMCV2yeKxIzLUUkVLAPOAeVT1c0PEEgoj0Bvaq6jeZH86iaSj/DUQAzYFXVLUZcIwQHV7JiufY\nQB+gJlAVKIkbcj1TKP8N5EswJPQiuRi1iBTDJfO3VHW+5+E9IlLF83wVYG9BxedHlwNXi8gvuOG1\nzrgee1nPz28I/b+BRCBRVdd67s/FJfii8P0DXAn8rKr7VPUkMB9oS9H6G8iXYEjoRW4xas+Y8Qwg\nQVWfz/TUImCI5/YQYGGgY/M3VX1IVWNUtQbuu/5cVQcDy4ABnmYh+d7Tqepu4FcRqet5qAvwPUXg\n+/fYCbQRkfM8/xbS33+R+RvIr6A4U1REeuJ6aemLUT9dwCH5lYi0A74ENpExjvwP3Dj6HKA67o9+\noKoeKJAgA0BEOgJjVLW3iNTC9djLAxuAG1Q1qSDj8ycRaYo7KBwJbAduxnXAisT3LyLjgOtwM742\nALfixsyLzN9AfgRFQjfGGJO7YBhyMcYY4wVL6MYYEyIsoRtjTIiwhG6MMSHCEroxxoQIS+jGGBMi\nLKEbY0yI+H8XnrzYUk7oGQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1427abd4860>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(range(0,100,5),stochastic_loss,'b-',label='stochastic loss')\n",
    "plt.plot(range(0,100,5),batch_loss,'r--',label='batch loss')\n",
    "plt.legend(loc='upper right',prop={'size':11})\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
